package com.bahehe.taoyunabus;

import java.util.ArrayList;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class BaseAdapterBusTime extends BaseAdapter {

	private static ArrayList<SearchResults> searchArrayList;
	private LayoutInflater mInflater;

	
	public BaseAdapterBusTime(Context context, ArrayList<SearchResults> results) {
		  searchArrayList = results;
		  mInflater = LayoutInflater.from(context);
	}
    
	

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return  searchArrayList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return searchArrayList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	 static class ViewHolder {
		  TextView txtBusStop;
		  TextView txtBusTime;
		  
	 }
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		
		 if (convertView==null) {
			   convertView = mInflater.inflate(R.layout.list_bustime, null);
			   holder = new ViewHolder();
			   holder.txtBusStop = (TextView) convertView.findViewById(R.id.txtBusStop);
			   holder.txtBusTime = (TextView) convertView.findViewById(R.id.txtBusTime);
			  
			   convertView.setTag(holder);
			  } else {
			   holder = (ViewHolder) convertView.getTag();
			  }
			  
		 	  holder.txtBusStop.setText(searchArrayList.get(position).getRoute_name());
		 	  holder.txtBusTime.setText(searchArrayList.get(position).getBustime());

		
	 	 return convertView;
	}

}
